﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Cluster.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The cluster.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Models.Domain
{
    using System;
    using System.Collections.Generic;

    using NHibernate.Mapping.ByCode.Conformist;

    using ServiceLibrary.Models.Base;

    /// <summary>
    /// The cluster.
    /// </summary>
    public class Cluster : Entity
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Cluster"/> class.
        /// </summary>
        public Cluster()
        {
            this.Profiles = new HashSet<Profile>();
            this.Statuses = new HashSet<ClusterStatus>();
            this.Methods = new HashSet<ClusterMethod>();
            this.OwnerProjects = new HashSet<Project>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the date.
        /// </summary>
        public virtual DateTime? Date { get; set; }

        /// <summary>
        /// Gets or sets the location.
        /// </summary>
        public virtual Location Location { get; set; }

        /// <summary>
        /// Gets or sets the nationality status.
        /// </summary>
        public virtual bool IsNational { get; set; }


        /// <summary>
        /// Gets or sets the methods.
        /// </summary>
        public virtual ICollection<ClusterMethod> Methods { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public virtual string Name { get; set; }

        /// <summary>
        /// Gets or sets the owner projects.
        /// </summary>
        public virtual ICollection<Project> OwnerProjects { get; set; }

        /// <summary>
        /// Gets or sets the profiles.
        /// </summary>
        public virtual ICollection<Profile> Profiles { get; set; }

        /// <summary>
        /// Gets or sets the statuses.
        /// </summary>
        public virtual ICollection<ClusterStatus> Statuses { get; set; }

        #endregion
    }

    /// <summary>
    /// The cluster mapping.
    /// </summary>
    public class ClusterMapping : ClassMapping<Cluster>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterMapping"/> class.
        /// </summary>
        public ClusterMapping()
        {
            this.Set(x => x.OwnerProjects, c => { }, m => m.ManyToMany());
            this.ManyToOne(x => x.Location);
            this.Property(x => x.Date);
            this.Property(x => x.IsNational);
            this.Property(x => x.Name);
            this.Set(x => x.Profiles, c => { }, m => m.ManyToMany());
            this.Set(x => x.Statuses, c => { }, m => m.ManyToMany());
            this.Set(x => x.Methods, c => { }, m => m.ManyToMany());
        }

        #endregion
    }
}